﻿#include "controlsystem.h"

QByteArray intToByte(int number)
{
    QByteArray abyte0;
    abyte0.resize(4);
    abyte0[3] = (uchar) (0x000000ff & number);
    abyte0[2] = (uchar) ((0x0000ff00 & number) >> 8);
    abyte0[1] = (uchar) ((0x00ff0000 & number) >> 16);
    abyte0[0] = (uchar) ((0xff000000 & number) >> 24);
    return abyte0;

}

bool sendCmd(QString  ss)
{
bool *ok=new bool;
QByteArray s=intToByte(ss.toUInt(ok,16));
if(onPhoto==1)
{

    file->write(std::to_string(timer->restart()).c_str());
    file->write("\n");
    file->write(ss.toStdString().data());//录制
    file->write("\n");
    qDebug()<<"saveing";
    //保存时间
    b_timeStr = QDateTime::currentDateTime().toString("yyyyMMddhhmmsszzz");
    //qdt1 = QDateTime::currentDateTime();
   // b_timeStr = qdt1.toString("yyyyMMddhhmmsszzz");

}
if(onBack==0)
{
mSocket->writeDatagram(s,host,port);
qDebug()<< s;
return 1;
}else
{
    return 0;
}

}
